Ext.BLANK_IMAGE_URL = 'extjs3/resources/images/default/s.gif';
Ext.onReady(function() {
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

	var topPanel = new Ext.BoxComponent({
				region : 'north',
				height : 60,
				applyTo : 'header',
				split : false
			});

	var centerPanel = new Ext.Panel({
				layout : 'fit',
				id : 'centerPanel',
				region : 'center',
				//deferredRender: false,
				//activeTab: 0,
				title : '欢迎页面',
				collapsible : true
			});

	var westPanel = new Ext.Panel({
				title : '功能菜单',
				id : 'west-panel',
				region : 'west',
				collapsible : true,
				split : true,
				width : 200,
				items : treeMenuPanel
			});

	var viewport = new Ext.Viewport({
				layout : 'border',
				items : [topPanel, westPanel, centerPanel]
			});

	initMenu();

});

function initMenu() {
	var menuData;//菜单数据.
	Ext.Ajax.request({
		url : 'menu.action?method=selectAll',
		method : 'GET',
		success : function(response, options) {
			var result = Ext.util.JSON.decode(response.responseText);
			if (result.success) {
				menuData = result.data;
				treeMenuPanel.loadCustomData(menuData);
				treeMenuPanel.expandAll();
			} else {
				Ext.Msg.alert('提示', '不能获取菜单信息.');
			}
		},
		failure : function(response, options) {
			Ext.Msg.alert('提示', '不能获取菜单信息.');
		}
	});
};
